#define _CRT_SECURE_NO_WARNINGS 1

#include <stdint.h>
#include <stdio.h>

int main() {
    int count = 0;
    int n;
    scanf("%d", &n);
    for (int i = 0; i <= n; ++i)
    {
        int size = 1;
        int j = i;
        while (j >= 10)
        {
            ++size;
            j /= 10;
        }
        int diff = 1;
        for (int a = 0; a < size; ++a)
        {
            diff *= 10;
        }
        if (i == (i * i % diff))
            ++count;
    }
    printf("%d", count);

    return 0;
}